﻿using System.Windows;
using Foundation;
using Poet.ViewModels;
using Poet.Views;

namespace Poet
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App
    {
        private void App_OnStartup(object sender, StartupEventArgs e)
        {           
            if(!InstanceManager.CanCreateInstance(e.Args))
                Current.Shutdown();

            var mainViewModel = new MainViewModel();  
            var trayView = new TrayView();
            var mainView = new MainView();
   
            Current.MainWindow = mainView;
            mainViewModel.Bind(trayView);
            mainViewModel.Bind(mainView);
            mainView.Show();

            var searchAndReplaceViewModel = new SearchAndReplaceViewModel(mainViewModel);
            var searchView = new SearchAndReplaceTabsView();
            mainViewModel.ToolViews.Add(searchView);
            searchAndReplaceViewModel.Bind(searchView);
            searchView.Show(mainView.DockingManager);
        }
    }
}
